import router from './index'
import cache from '../utils/cache'

const whiteList = ['/login']

router.beforeEach((to, from, next) => {
    if (whiteList.includes(to.path)) {
        next()
    } else {
        const token = cache.session.get('token')
        if (!token) {
            next('/login')
            return
        }
        next()
    }
})